<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html style="height:100%;">
    <head></head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="stylesheet" href="../../lib/layui/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="../css/base.css">
    <script type="text/javascript" src="/js/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="/js/zTree/jquery.ztree.core.js"></script>
    <link rel="stylesheet" type="text/css" href="/css/zTreeStyle/zTreeStyle.css"/>
    <script type="text/javascript" src="/lib/layer/layer.js?20201106"></script>
    <script type="text/javascript" src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" src="../../lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/js/base/base.js"></script>
    <title></title>
    <style>
        .fl{
            float: left;
        }
        .clearfix:after{
            display: block;
            clear:both;
            height:0;
            content: "";
        }
        .foot,.foots{
            position: absolute;
            left: 20px;
            right: 0;
            bottom: 10%;
        }
        .newcolumn{
            background-color: rgb(91, 192, 222);
        }

        .mos{
            background: #eaf1ff;
            width: 80px;
            height:28px;
            cursor:pointer;
            border:1px solid #d0def3 ;
            border-radius: 3px;
        }

        .mos2{
            background: #5cb85c;
            width: 90px;
            height:28px;
            cursor:pointer;
            color: #fff;
            border:1px solid #4cae4c ;
            border-radius: 3px;
        }

        .mos:hover{
            background-color: #f3f7ff;
        }
        .recycle{
            background: #f0ad4e;
            width: 105px;
            height:28px;
            cursor:pointer;
            border:1px solid #eea236 ;
            border-radius: 3px;
            color: #fff;
        }
        .issue{
            background: #347cee;
            width: 100px;
            height:28px;
            cursor:pointer;
            border:1px solid #196aeb ;
            border-radius: 3px;
            color: #fff;
        }

        .editor{
            background: mediumseagreen;
            width: 100px;
            height:28px;
            cursor:pointer;
            border:1px solid forestgreen;
            border-radius: 3px;
            color: #fff;
        }



        .delcolumn,.newcolumn,.delcolumns,.dels{
            width:105px;
            height:28px;
            color:#fff;
            cursor:pointer;
            border-radius: 3px;

        }
        #edit{
            cursor:pointer;
            width:18px;
            height:18px;
        }

        .edit{
            cursor: pointer;
        }
        .delcolumn,.dels{
            background-color: rgb(217, 83, 79);
        }

        .delcolumns{
            background-color: #f0ad4e;
        }
        .columnCount{
            height: 150px;
            width: 110px;
            margin-right:10px;
        }
        .count{
            margin-top:30px;
        }
        .table tr{
            border:none;
        }
        .table td{
            text-align: center;
            padding:5px 0 5px 0;
        }
        .jichu{
            text-align: center;
            font-weight: bold;
        }
        .w150{
            width:150px;
        }
        .input{
            width:139px;
            border-radius: 3px;
            margin-left: -29px;
        }
        .table{
            width:95%;
            margin:10px auto;
        }
        .layui-layer-btn{
            text-align: center !important;
        }
        b{
            color: red;
            font-size: 18px;
            position: relative;
            top:5px;
            left:5px;
        }
    </style>
    <body style="height:100%;padding-left: 10px;">
        <div class="iofo">
           <div class="title" style="margin-top: 10px">
               <span class="anl" style="color: red;display: none">（栏目回收站）</span>
               <span>当前位置：</span>
               <span class="court"></span>
           </div>
            <div class="count clearfix">

            </div>
            <div class="foot" >
                <button class="newcolumn">创建栏目</button>
                <button class="delcolumn">删除栏目</button>
                <%--<button class="mos mome" style="margin-left: 8px">移动</button>--%>
                <%--<button class="mos copy">复制</button>--%>
                <button class="mos look">预览</button>
                <button class="recycle" style="margin-left: 8px">栏目回收站</button>
                <button class="issue">栏目发布</button>
                <button class="editor">编辑</button>
            </div>

            <div class="foots" style="display:none;">
                <button class="mos retn">返回</button>
                <button class="mos2 restore">还原</button>
                <button class="dels">删除栏目</button>
                <button class="delcolumns">清空回收站</button>

            </div>
            
        </div>
    </body>
    <script>
        $(function(){
            var id=window.parent.parentid;//得到父元素当前点击id
            var extend1=window.parent.extend1;//得到父元素当前点击extend1



            var channelId = id.split(';');
            var type=channelId[1];
            channelId = channelId[0]
            if (type=='site'){
                channelId=0;
                $('.editor').hide()
            }

//            alert('当前id'+channelId)
//            alert('站点id'+extend1)
            var nodesid=window.parent.nodesid;//得到得到父元素当前点击id，站点id
            var zTree=window.parent.treeDemo;//得到父元素的树的元素
             //console.log(nodesid)

            function renovate(){//新建,删除刷新树节点方法
                type = "refresh",
                silent = false,
                nodes = zTree.getSelectedNodes();  /*获取 zTree 当前被选中的节点数据集合*/
                zTree.reAsyncChildNodes(nodes[0], type, silent);
                /*强行异步加载父节点的子节点。[setting.async.enable = true 时有效]*/
            }
            str="";
            for(i=0;i<id.length;i++) {//得到id的数字
                if("0123456789".indexOf(id.substr(i,1))>-1)
                    str+=id.substr(i,1)
            }
            var pid=str;

            num="";
            for(i=0;i<nodesid.length;i++) {
                if("0123456789".indexOf(nodesid.substr(i,1))>-1)
                    num+=nodesid.substr(i,1)
            }
            var number=num;//得到得到父元素当前点击id，站点id

            //栏目展示
            $.ajax({
                url:'/cmsChannel/listChannels',
                data:{siteId:extend1,channelId:channelId},
                type:'get',
                dataType:'json',
                success:function(res){
                    if(res.flag){
                        var data=res.data;
                        var lis = data.list
                        var str='';
                      //  console.log(lis)
                        if(lis.length !=0){

                            for(var i=0;i<lis.length;i++){
                                str+='<div class="fl columnCount">' +
                                    '<div class="edit" columnId='+lis[i].sid+' siteId='+lis[i].siteId+'><img src="/img/cms/file.png" alt=""></div>' +
                                    '<p style="text-align: center">' +
                                    '<input value='+lis[i].sid+' path='+lis[i].path+' class="choice" type="checkbox">' +
                                    '<span id="edit" class="edit" columnId='+lis[i].sid+' siteId='+lis[i].siteId+' style="display:inline-block;"><img src="/img/cms/edit.png" alt=""></span>'+
                                    '<span >'+lis[i].chnlName+'</span>' +
                                    '</p>' +
                                    '</div>'
                            }
                            $('.count').html(str)
                        }else {
                            str='<div><img src="/img/ts1.png" alt=""></div>'
                            $('.count').html(str)

                        }

                        $('.court').html(data.path)
                    }
                }
            })
//            栏目发布
            $('.issue').click(function(){
                var chooseid='';
                for(var i=0;i<$('.columnCount>.edit').length;i++){
                    chooseid += $('.columnCount>.edit').eq(i).attr('columnid')+','
                }
                $.ajax({
                    url:'/cmsChannel/updateStatus',
                    dataType:'json',
                    type:'get',
                    data:{
                        columnid:chooseid,
                        status:1
                    },
                    success:function(res){
                        if(res.flag){
                            $.layerMsg({content:'发布成功',icon:1});
                            window.location.reload();
                        }else{
                            $.layerMsg({content:'发布失败',icon:2})
                        }
                    }
                })
            })

//新建
            $('.newcolumn').click(function(){
                layer.open({
                    type: 1,
                    title:['创建栏目', 'background-color:#2b7fe0;color:#fff;'],
                    area: ['650px', '420px'],
                    content:'<div>' +
                                '<table class="table">' +
                                    '<tr><td colspan="4" style="background:#f0f0f0;"><p class="jichu">基础信息</p></td></tr>'+
                                    '<tr><td class="w150">栏目标识:</td><td><input id="columnMark" class="input" type="text" style="margin-left:-13%;"><b>*</b></td><td class="w150">显示名称:</td><td><input id="columnName" class="input" type="text" ><b>*</b></td></tr>' +
                                    '<tr><td>排序号:</td><td><input id="sortNo" class="input" type="text"></td><td>栏目分页大小:</td><td><input id="pageSize" class="input" type="text"><b>*</b></td></tr>' +
//                                    '<tr><td>栏目分页大小:</td><td><input id="pageSize" style="margin-left:-20px;" class="input" type="text"><b>*</b></td><td></td><td></td></tr>' +
                                    '<tr style="height:20px;"><td colspan="4"></td></tr>' +
                                    '<tr><td colspan="4" style="background:#f0f0f0;"><p class="jichu">发布相关</p></td></tr>'+
                                    '<tr><td>首页模板:</td><td><select name="" id="listTemplate"></select></td><td></td><td></td></tr>' +
                                    '<tr><td>细缆模板:</td><td><select name="" id="cablet"></select></td><td></td><td></td></tr>' +
                                '</table>' +
                            '</div>',
                             btn: ['保存','取消'],
                             success:function(){
                                 $.ajax({//模板展示
                                     url:'/cmsMoudle/listTemplates',
                                     type:'get',
                                     data:{siteId:extend1},
                                     dataType:'json',
                                     success:function(res){
                                         var data=res.data;
                                         var str='';
                                         var datas='';
                                         for(var i=0;i<data.length;i++){
                                             str+='<option value='+data[i].sid+' templateId='+data[i].sid+'>'+data[i].tplName+'</option>'
                                             datas+='<option value='+data[i].sid+' templateId='+data[i].sid+'>'+data[i].tplName+'</option>'
                                         }
                                         $('#listTemplate').html(str);
                                         $('#cablet').html(datas);
                                     }
                                 })
                             },
                             btn1:function(){//新建保存
                                 if($('#columnMark').val()==''){
                                     layer.msg('请填写栏目标识', { icon:6});
                                     return false;
                                 }
                                 if($('#columnName').val()==''){
                                     layer.msg('请填写名称', { icon:6});
                                     return false;
                                 }
                                 if($('#path').val()==''){
                                     layer.msg('请填存放位置', { icon:6});
                                     return false;
                                 }
                                 if($('#pageSize').val()==''){
                                     layer.msg('请填栏目分页', { icon:6});
                                     return false;
                                 }
                                 var idss=window.parent.parentid;
                                // console.log(idss)
                                 var aa=idss.substring(idss.length-4);//截取后4位字符串
                                // console.log(aa)
                                var site='site'
                                if(site==aa){
                                    parentColumnid=0;
                                 }else {
                                    parentColumnid=pid;

                                 }
                                 $.ajax({
                                     url:'/cmsChannel/addChannelInfo',
                                     type:'get',
                                     data:{
//                                         portalId:number,
                                         chnlIdentity:$('#columnMark').val(),//标识
                                         chnlName:$('#columnName').val(),//显示名称
                                         sortNo:$('#sortNo').val(),//排序号
                                         folder:$('#path').val(),//存放位置
                                         pageSize:$('#pageSize').val(),//栏目分页大小
                                         indexTpl:$('#listTemplate option:checked').attr('templateId'),
                                         detailTpl:$("#cablet option:checked").attr('templateId'),
//                                         parentColumnId:parentColumnid
                                         status:1,
                                         siteId:extend1,
                                         parentChnl:channelId
                                     },
                                     dataType:'json',
                                     success:function(){
                                         renovate();
                                         location.reload();
                                     }
                                 })
                             }


                })
            })

//删除
            $(".delcolumn").click(function(){
                var del= $("input[type='checkbox']").is(':checked');
                var path= $("input[type='checkbox']").attr('path');
                var ids=[];
                if(del==true){
                   $.each($('input:checkbox:checked'),function(){
                       var columnId=$(this).val();
                       ids.push(columnId)
                   });

                    layer.confirm('确认要将所选栏目放置回收站吗？', {
                        btn: ['确定','取消'], //按钮
                        title:"确定删除？"
                    },function(){
                        $.ajax({
                            url:'/cmsChannel/moveToTrash',
                            type:'get',
                            data:{sids:ids},
                            dataType:'json',
                            success:function(){
                                location.reload();
                                renovate();
                            }
                        });
                        layer.msg('删除成功', { icon:6,time:1000});
                    })
               }else{
                   alert('请至少选择一个要删除的栏目')
               }

            })

//编辑
            $('.count').on('click','.edit',function(){
               var columnId=$(this).attr('columnId');
                var siteId=$(this).attr('siteId');
//                console.log(columnId)
//                console.log(siteId)

                layer.open({
                    type: 1,
                    title:['编辑栏目', 'background-color:#2b7fe0;color:#fff;'],
                    area: ['650px', '420px'],
                    content:'<div>' +
                    '<table class="table">' +
                    '<tr><td colspan="4" style="background:#f0f0f0;"><p class="jichu">基础信息</p></td></tr>'+
                    '<tr><td class="w150">栏目标识:</td><td><input name="columnMark" class="input" type="text"><b>*</b></td><td class="w150">显示名称:</td><td><input name="columnName" class="input" type="text"><b>*</b></td></tr>' +
                    '<tr><td>排序号:</td><td><input name="sortNo" style="margin-left:-25%;" class="input" type="text"></td><td>栏目分页大小:</td><td><input name="pageSize" class="input" style="margin-left:-25%;" type="text"><b>*</b></td></tr>' +
//                    '<tr><td>栏目分页大小:</td><td><input name="pageSize" class="input" type="text"><b>*</b></td><td></td><td></td></tr>' +
                    '<tr style="height:20px;"><td colspan="4"></td></tr>' +
                    '<tr><td colspan="4" style="background:#f0f0f0;"><p class="jichu">发布相关</p></td></tr>'+
                    '<tr><td>首页模板:</td><td><select name="listTemp" class="listTemp"></select></td><td></td><td></td></tr>' +
                    '<tr><td>细缆模板:</td><td><select name="cablet" class="cablet"></select></td><td></td><td></td></tr>' +
                    '</table>' +
                    '</div>',
                    btn: ['保存','取消'],
                    success:function(){

                            $.ajax({//模板展示
                                url:'/cmsMoudle/listTemplates',
                                type:'get',
                                async: false,
                                data:{siteId:siteId},
                                dataType:'json',
                                success:function(res){
                                    var data=res.data;
                                    var str='';
                                    var datas='';
                                    for(var i=0;i<data.length;i++){
                                        str+='<option value='+data[i].sid+' templateId='+data[i].sid+'>'+data[i].tplName+'</option>'
                                        datas+='<option value='+data[i].sid+' templateId='+data[i].sid+'>'+data[i].tplName+'</option>'
                                    }
                                    $('.listTemp').html(str);
                                    $('.cablet').html(datas);
                                }
                            })

                            $.ajax({//信息回显
                                url:'/cmsChannel/getChannelInfo',
                                type:'get',
                                async: false,
                                data:{sid:columnId},
                                dataType:'json',
                                success:function(res){
                                    var data=res.data;
                                    if(res.flag){
                                        $('input[name="columnMark"]').val(data.chnlIdentity);
                                        $('input[name="columnName"]').val(data.chnlName);
                                        $('input[name="sortNo"]').val(data.sortNo);
                                        $('input[name="pageSize"]').val(data.pageSize);
                                        $('input[name="path"]').val(data.folder);
                                        $(".listTemp").val(data.indexTpl);
                                        $(".cablet").val(data.detailTpl);
                                    }
                                }
                            })


                    },
                    btn1:function(){//编辑保存
                        if($('input[name="columnMark"]').val()==''){
                            layer.msg('请填存放位置', { icon:6});
                            return false;
                        }
                        if($('input[name="columnName"]').val()==''){
                            layer.msg('请填名称', { icon:6});
                            return false;
                        }
//                        if($('input[name="path"]').val()==''){
//                            layer.msg('请填存放位置', { icon:6});
//                            return false;
//                        }
                        if($('input[name="pageSize"]').val()==''){
                            layer.msg('请填栏目分页大小', { icon:6});
                            return false;
                        }
                        data={
                            chnlIdentity:$('input[name="columnMark"]').val(),//标识
                            chnlName:$('input[name="columnName"]').val(),//显示名称
                            sortNo:$('input[name="sortNo"]').val(),//排序号
                            folder:$('input[name="path"]').val(),//存放位置
                            pageSize:$('input[name="pageSize"]').val(),//栏目分页大小
                            indexTpl:$('.listTemp option:checked').attr('templateId'),
                            detailTpl:$(".cablet option:checked").attr('templateId'),
//                                         parentColumnId:parentColumnid
                            status:1,
                            sid:columnId,
                            siteId:extend1,
                            parentChnl:channelId
                        }
                        $.ajax({
                            url:'/cmsChannel/updateChannelInfo',
                            type:'get',
                            data:data,
                            dataType:'json',
                            success:function(res){
                                location.reload();
                            }
                        })
                    },
                })
            })


            //编辑
            $(document).on('click','.editor',function(){
                var columnId=channelId;
                var siteId=extend1;
//                console.log(columnId)
//                console.log(siteId)

                layer.open({
                    type: 1,
                    title:['编辑栏目', 'background-color:#2b7fe0;color:#fff;'],
                    area: ['650px', '420px'],
                    content:'<div>' +
                    '<table class="table">' +
                    '<tr><td colspan="4" style="background:#f0f0f0;"><p class="jichu">基础信息</p></td></tr>'+
                    '<tr><td class="w150">栏目标识:</td><td><input name="columnMark" class="input" type="text"><b>*</b></td><td class="w150">显示名称:</td><td><input name="columnName" class="input" type="text"><b>*</b></td></tr>' +
                    '<tr><td>排序号:</td><td><input name="sortNo" style="margin-left:-25%;" class="input" type="text"></td><td>栏目分页大小:</td><td><input name="pageSize" class="input" style="margin-left:-25%;" type="text"><b>*</b></td></tr>' +
//                    '<tr><td>栏目分页大小:</td><td><input name="pageSize" class="input" type="text"><b>*</b></td><td></td><td></td></tr>' +
                    '<tr style="height:20px;"><td colspan="4"></td></tr>' +
                    '<tr><td colspan="4" style="background:#f0f0f0;"><p class="jichu">发布相关</p></td></tr>'+
                    '<tr><td>首页模板:</td><td><select name="listTemp" class="listTemp"></select></td><td></td><td></td></tr>' +
                    '<tr><td>细缆模板:</td><td><select name="cablet" class="cablet"></select></td><td></td><td></td></tr>' +
                    '</table>' +
                    '</div>',
                    btn: ['保存','取消'],
                    success:function(){

                        $.ajax({//模板展示
                            url:'/cmsMoudle/listTemplates',
                            type:'get',
                            async: false,
                            data:{siteId:siteId},
                            dataType:'json',
                            success:function(res){
                                var data=res.data;
                                var str='';
                                var datas='';
                                for(var i=0;i<data.length;i++){
                                    str+='<option value='+data[i].sid+' templateId='+data[i].sid+'>'+data[i].tplName+'</option>'
                                    datas+='<option value='+data[i].sid+' templateId='+data[i].sid+'>'+data[i].tplName+'</option>'
                                }
                                $('.listTemp').html(str);
                                $('.cablet').html(datas);
                            }
                        })

                        $.ajax({//信息回显
                            url:'/cmsChannel/getChannelInfo',
                            type:'get',
                            async: false,
                            data:{sid:columnId},
                            dataType:'json',
                            success:function(res){
                                var data=res.data;
                                if(res.flag){
                                    $('input[name="columnMark"]').val(data.chnlIdentity);
                                    $('input[name="columnName"]').val(data.chnlName);
                                    $('input[name="sortNo"]').val(data.sortNo);
                                    $('input[name="pageSize"]').val(data.pageSize);
                                    $('input[name="path"]').val(data.folder);
                                    $(".listTemp").val(data.indexTpl);
                                    $(".cablet").val(data.detailTpl);
                                }
                            }
                        })


                    },
                    btn1:function(){//编辑保存
                        if($('input[name="columnMark"]').val()==''){
                            layer.msg('请填存放位置', { icon:6});
                            return false;
                        }
                        if($('input[name="columnName"]').val()==''){
                            layer.msg('请填名称', { icon:6});
                            return false;
                        }
//                        if($('input[name="path"]').val()==''){
//                            layer.msg('请填存放位置', { icon:6});
//                            return false;
//                        }
                        if($('input[name="pageSize"]').val()==''){
                            layer.msg('请填栏目分页大小', { icon:6});
                            return false;
                        }
                        data={
                            chnlIdentity:$('input[name="columnMark"]').val(),//标识
                            chnlName:$('input[name="columnName"]').val(),//显示名称
                            sortNo:$('input[name="sortNo"]').val(),//排序号
                            folder:$('input[name="path"]').val(),//存放位置
                            pageSize:$('input[name="pageSize"]').val(),//栏目分页大小
                            indexTpl:$('.listTemp option:checked').attr('templateId'),
                            detailTpl:$(".cablet option:checked").attr('templateId'),
//                                         parentColumnId:parentColumnid
                            status:1,
                            sid:columnId,
                            siteId:extend1,
                            parentChnl:channelId
                        }
                        $.ajax({
                            url:'/cmsChannel/updateChannelInfo',
                            type:'get',
                            data:data,
                            dataType:'json',
                            success:function(res){
                                location.reload();
                            }
                        })
                    },
                })
            })

// 预览
            $('.look').click(function () {
                var columnId=''
                if($('input:checkbox:checked').length == 1){
                    $.each($('input:checkbox:checked'),function(){
                         columnId=$(this).val();
                    });
                    window.open("/cmsPub/portal?siteId="+extend1+"&channelId="+columnId);
                }else {
                    alert('一次只能阅览一个栏目')
                }
            })


     //  栏目回收站
        $('.recycle').click(function () {

            //回收站栏目展示
            $.ajax({
                url:'/cmsChannel/listTrashChannels',
                data:{siteId:extend1,channelId:channelId},
                type:'get',
                dataType:'json',
                success:function(res){
                    var data=res.data;
                    var lis = data.list
                    var str='';
                  //  console.log(lis)
                    if(lis.length !=0){

                        for(var i=0;i<lis.length;i++){
                            str+='<div class="fl columnCount">' +
                                '<div><img src="/img/cms/file.png" alt=""></div>' +
                                '<p style="text-align: center">' +
                                '<input value='+lis[i].sid+' path='+lis[i].path+' class="choice" type="checkbox">' +
//                                '<span id="edit" columnId='+lis[i].sid+' siteId='+lis[i].siteId+' style="display:inline-block;"><img src="/img/cms/edit.png" alt=""></span>'+
                                '<span style="margin-left: 6px">'+lis[i].chnlName+'</span>' +
                                '</p>' +
                                '</div>'
                        }
                        $('.count').html(str)
                    }else {
                        str='<div><img src="/img/tss.png" alt=""></div>'
                        $('.count').html(str)

                    }

                    $('.court').html(data.path)
                    $('.foot').hide();
                    $('.foots').show();
                    $('.anl').show();
                }
            })

        })

     //  栏目回收站(返回）
        $('.retn').click(function () {

            //栏目展示
            $.ajax({
                url:'/cmsChannel/listChannels',
                data:{siteId:extend1,channelId:channelId},
                type:'get',
                dataType:'json',
                success:function(res){
                    if(res.flag){
                        var data=res.data;
                        var lis = data.list
                        var str='';
                      //  console.log(lis)
                        if(lis.length !=0){

                            for(var i=0;i<lis.length;i++){
                                str+='<div class="fl columnCount">' +
                                    '<div><img src="/img/cms/file.png" alt=""></div>' +
                                    '<p style="text-align: center">' +
                                    '<input value='+lis[i].sid+' path='+lis[i].path+' class="choice" type="checkbox">' +
                                    '<span id="edit" columnId='+lis[i].sid+' siteId='+lis[i].siteId+' style="display:inline-block;"><img src="/img/cms/edit.png" alt=""></span>'+
                                    '<span >'+lis[i].chnlName+'</span>' +
                                    '</p>' +
                                    '</div>'
                            }
                            $('.count').html(str)
                        }else {
                            str='<div><img src="/img/ts1.png" alt=""></div>'
                            $('.count').html(str)

                        }

                        $('.court').html(data.path)
                        $('.foot').show();
                        $('.foots').hide();
                        $('.anl').hide();

                    }
                }
            })
        })

     //  栏目回收站(还原）
            $('.restore').click(function () {
                var del= $("input[type='checkbox']").is(':checked');
                var path= $("input[type='checkbox']").attr('path');
                var ids=[];
                if(del==true){
                    $.each($('input:checkbox:checked'),function(){
                        var columnId=$(this).val();
                        //console.log(columnId)
                        ids.push(columnId)
                        // console.log(arr)
                    });
                    layer.confirm('确定要还原栏目吗？', {
                        btn: ['确定','取消'], //按钮
                        title:"确定还原？"
                    },function(){
                        $.ajax({
                            url:'/cmsChannel/recycle',
                            type:'get',
                            data:{sid:ids.join('')},
                            dataType:'json',
                            success:function(){

                                //回收站栏目展示
                                $.ajax({
                                    url:'/cmsChannel/listTrashChannels',
                                    data:{siteId:extend1,channelId:channelId},
                                    type:'get',
                                    dataType:'json',
                                    success:function(res){
                                        var data=res.data;
                                        var lis = data.list
                                        var str='';
                                      //  console.log(lis)
                                        if(lis.length !=0){

                                            for(var i=0;i<lis.length;i++){
                                                str+='<div class="fl columnCount">' +
                                                    '<div><img src="/img/cms/file.png" alt=""></div>' +
                                                    '<p style="text-align: center">' +
                                                    '<input value='+lis[i].sid+' path='+lis[i].path+' class="choice" type="checkbox">' +
//                                '<span id="edit" columnId='+lis[i].sid+' siteId='+lis[i].siteId+' style="display:inline-block;"><img src="/img/cms/edit.png" alt=""></span>'+
                                                    '<span style="margin-left: 6px">'+lis[i].chnlName+'</span>' +
                                                    '</p>' +
                                                    '</div>'
                                            }
                                            $('.count').html(str)
                                        }else {
                                            str='<div><img src="/img/tss.png" alt=""></div>'
                                            $('.count').html(str)

                                        }

                                        $('.court').html(data.path)
                                    }
                                })


                            }
                        });
                        layer.msg('还原成功', { icon:6,time:1000});
                    })
                }else{
                    alert('请至少选择一个要还原的栏目')
                }
            })

     //  栏目回收站(删除）
            $('.dels').click(function () {
                var del= $("input[type='checkbox']").is(':checked');
                var path= '';
                var ids=[];
                var paths=[];
                if(del==true){
                    $.each($('input:checkbox:checked'),function(){
                        var columnId=$(this).val();
                        path=$(this).attr('path')
                        //console.log(columnId)
                        ids.push(columnId)
                        paths.push(path)
                        // console.log(arr)
                    });
                    layer.confirm('确认要彻底删除所选栏目吗？', {
                        btn: ['确定','取消'], //按钮
                        title:"确定删除？"
                    },function(){
                        $.ajax({
                            url:'/cmsChannel/delChannelInfo',
                            type:'get',
                            data:{paths:paths},
                            dataType:'json',
                            success:function(){
                                //回收站栏目展示
                                $.ajax({
                                    url:'/cmsChannel/listTrashChannels',
                                    data:{siteId:extend1,channelId:channelId},
                                    type:'get',
                                    dataType:'json',
                                    success:function(res){
                                        var data=res.data;
                                        var lis = data.list
                                        var str='';
                                     //   console.log(lis)
                                        if(lis.length !=0){
                                            for(var i=0;i<lis.length;i++){
                                                str+='<div class="fl columnCount">' +
                                                    '<div><img src="/img/cms/file.png" alt=""></div>' +
                                                    '<p style="text-align: center">' +
                                                    '<input value='+lis[i].sid+' path='+lis[i].path+' class="choice" type="checkbox">' +
//                                '<span id="edit" columnId='+lis[i].sid+' siteId='+lis[i].siteId+' style="display:inline-block;"><img src="/img/cms/edit.png" alt=""></span>'+
                                                    '<span style="margin-left: 6px">'+lis[i].chnlName+'</span>' +
                                                    '</p>' +
                                                    '</div>'
                                            }
                                            $('.count').html(str)
                                        }else {
                                            str='<div><img src="/img/tss.png" alt=""></div>'
                                            $('.count').html(str)

                                        }

                                        $('.court').html(data.path)
                                    }
                                })
                            }
                        });
                        layer.msg('删除成功', { icon:6,time:1000});
                    })
                }else{
                    alert('请至少选择一个要删除的栏目')
                }
            })

     //  栏目回收站(清空回收站）
            $(".delcolumns").click(function(){
                var del= $("input[type='checkbox']").is(':checked');
                var path= $("input[type='checkbox']").attr('path');
                var ids=[];

                    layer.confirm('确定要清空该栏目回收站吗？', {
                        btn: ['确定','取消'], //按钮
                        title:"确定清空？"
                    },function(){
                        $.ajax({
                            url:'/cmsChannel/clearTrash',
                            type:'get',
                            data:{siteId:extend1,channelId:channelId},
                            dataType:'json',
                            success:function(){
                                //回收站栏目展示
                                $.ajax({
                                    url:'/cmsChannel/listTrashChannels',
                                    data:{siteId:extend1,channelId:channelId},
                                    type:'get',
                                    dataType:'json',
                                    success:function(res){
                                        var data=res.data;
                                        var lis = data.list
                                        var str='';
                                     //   console.log(lis)
                                        if(lis.length !=0){

                                            for(var i=0;i<lis.length;i++){
                                                str+='<div class="fl columnCount">' +
                                                    '<div><img src="/img/cms/file.png" alt=""></div>' +
                                                    '<p style="text-align: center">' +
                                                    '<input value='+lis[i].sid+' path='+lis[i].path+' class="choice" type="checkbox">' +
//                                '<span id="edit" columnId='+lis[i].sid+' siteId='+lis[i].siteId+' style="display:inline-block;"><img src="/img/cms/edit.png" alt=""></span>'+
                                                    '<span style="margin-left: 6px">'+lis[i].chnlName+'</span>' +
                                                    '</p>' +
                                                    '</div>'
                                            }
                                            $('.count').html(str)
                                        }else {
                                            str='<div><img src="/img/tss.png" alt=""></div>'
                                            $('.count').html(str)

                                        }

                                        $('.court').html(data.path)
                                    }
                                })
                            }
                        });
                        layer.msg('清空成功', { icon:6,time:1000});
                    })

            })



        })
    </script>
</html>